import server from '@/config/server'

function post(path, auth = true, config = true) {
  return server.api().post(path).auth(auth).config(config)
}
function get(path, auth = true, config = true) {
  return server.api().get(path).auth(auth).config(config)
}

const api = {
  statistics: post('/dt-marketing/buildingPoster/statistics'), //霸屏神器内容管理统计接口
  statisticsByAdviser: post('/dt-marketing/buildingPoster/statisticsByAdviser'), //霸屏神器顾问统计接口
  statisticsByBuilding: post('/dt-marketing/buildingPoster/statisticsByBuilding'), //霸屏神器案场统计接口
  exportAdviserStatistics: post('/dt-marketing/buildingPoster/exportAdviserStatistics').tag('downloadCenter'), //案场海报统计表(顾问统计)导出
  exportBuildingStatistics: post('/dt-marketing/buildingPoster/exportBuildingStatistics').tag(
    'downloadCenter'
  ), //案场海报统计表(案场统计)导出
  exportStatistics: post('/dt-marketing/buildingPoster/exportStatistics').tag('downloadCenter'), //案场海报统计表(内容管理)导出

  deleteById: get('/dt-marketing/buildingPoster/delBuildingPoster'), //删除短文章

  adviserBuildingPoster: post('/dt-marketing/buildingPoster/adviserBuildingPoster'), //顾问案场海报推广详情
  exportAdviserBuildingPoster: post('/dt-marketing/buildingPoster/exportAdviserBuildingPoster').tag(
    'downloadCenter'
  ) //顾问案场海报推广详情导出
}

function getListData(params) {
  if (params.curState == 'case') {
    return api.statisticsByBuilding.fetch(params)
  } else if (params.curState == 'user') {
    return api.statisticsByAdviser.fetch(params)
  } else if (params.curState == 'content') {
    return api.statistics.fetch(params)
  }
}

function exportListData(params) {
  if (params.curState == 'case') {
    return api.exportBuildingStatistics.fetch(params)
  } else if (params.curState == 'user') {
    return api.exportAdviserStatistics.fetch(params)
  } else if (params.curState == 'content') {
    return api.exportStatistics.fetch(params)
  }
}

function deleteById(params) {
  return api.deleteById.fetch(params)
}

function getAdviserBuildingPoster(params) {
  return api.adviserBuildingPoster.fetch(params)
}

function exportAdviserBuildingPoster(params) {
  return api.exportAdviserBuildingPoster.fetch(params)
}

export default {
  getListData,
  deleteById,
  exportListData,
  getAdviserBuildingPoster,
  exportAdviserBuildingPoster
}
